package net.openadventure;

import java.awt.image.BufferedImage;

/**
 * ScreenElement is an image to be drawn on the foreground canvas. The Engine
 * converts a Sprite object to a ScreenElement object before sending it to the
 * ForegroundCanvas to be drawn. A ScreenElement is immutable. Once made, it can
 * not be changed.
 * 
 * @author Paul
 * 
 */
public final class ScreenElement {

    private BufferedImage image; // The image that this element displays

    private int x; // The distance from the left of the canvas to paint this

    // element

    private int y; // The distance from the top of the canvas to paint this

    // element

    /**
     * Creates a new ScreenElement object
     * 
     * @param image
     *            the BufferedImage to paint on the canvas.
     * @param x
     *            the distance from the left of the canvas to paint this element
     * @param y
     *            the distance from the top of the canvas to paint this element
     * @throws NullPointerException
     *             if the image parameter is null
     */
    public ScreenElement(BufferedImage image, int x, int y) {
        // Check parameters
        if (image == null) {
            throw new NullPointerException("Parameter image can not be null.");
        }

        this.image = image;
        this.x = x;
        this.y = y;
    }

    /**
     * Gets the BufferedImage contained in this ScreenElement
     * 
     * @return the BufferedImage
     */
    public BufferedImage getImage() {
        return image;
    }

    /**
     * Gets the x coordinate of the upper left corner of this ScreenElement.
     * This is the distance from the left side of the canvas.
     * 
     * @return the x coordinate
     */
    public int getX() {
        return x;
    }

    /**
     * Gets the y coordinate of the upper left corner of this ScreenElement.
     * This is the distance from the top of the canvas.
     * 
     * @return the y coordinate
     */
    public int getY() {
        return y;
    }
}
